import os
import sys

try:
    import mypyutils
except ImportError:
    # Some quick and dirty guesses where mypyutils could be
    RELATIVE_PATHS = [
        os.path.join('.'),
        os.path.join('mypyutils'),
        os.path.join('mypyutils', 'trunk'),
        os.path.join('..'),
        os.path.join('..', 'mypyutils'),
        os.path.join('..', 'mypyutils', 'trunk'),
        os.path.join('..', '..'),
        os.path.join('..', '..', 'mypyutils'),
        os.path.join('..', '..', 'mypyutils', 'trunk'),
        os.path.join('..', '..', '..'),
        os.path.join('..', '..', '..', 'mypyutils'),
        os.path.join('..', '..', '..', 'mypyutils', 'trunk'),
    ]
    for relative_path in RELATIVE_PATHS:
        absolute_path = os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path))
        if os.path.isfile(os.path.join(absolute_path, 'mypyutils', '__init__.py')):
            sys.path.append(absolute_path)
            print 'Auto-detected mypyutils at: ', absolute_path
            break
